home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / btngo.zip / BTNGOC.ZIP / WSTRING.HPP < prev   
C/C++ Source or Header  |  1993-09-28  |  2KB  |  45 lines

  1. /*
  2.     Copyright (c) 1993 John Deurbrouck, Box 390, Mountlake Terrace, WA 98043
  3.  
  4.     class WinMessageString used to accumulate data to show through MessageBox()
  5.  
  6.     SetHwndParent() sets the parent window handle for the MessageBox(). Defaults to NULL.
  7.     SetStyle() sets style to be OR'ed with MB_OK for MessageBox(). Defaults to MB_ICONSTOP.
  8.     show() shows accumulated data, with passed caption (defaults to "Error"), in MessageBox() call
  9.     SetHex(0), the default state, makes integral types show in decimal. SetHex(1) shows them in hex.
  10.     Use WinMessageString much like a iostream class, using << insertion operator. << is overloaded
  11.         for types listed below (now char __far *,char *, int, long, unsigned int, unsigned long).
  12.  
  13.     Normal usage:
  14.         #include"wstring.hpp"
  15.             ...
  16.             WinMessageString s;
  17.             s<<"hello "<<4<<" there";
  18.             s.show("Caption");
  19. */
  20. class WinMessageString{
  21.     enum a{ARRSIZE=1000};
  22.     char arr[ARRSIZE+1];
  23.     int space_left,is_hex;
  24.     unsigned long hwndParent;
  25.     unsigned long fuStyle;
  26.     void SetDefaults();
  27.     void err();
  28.     inline char *avail(){return &arr[ARRSIZE-space_left];}
  29. public:
  30.     WinMessageString(){hwndParent=NULL;SetDefaults();};
  31.     void SetHwndParent(unsigned long hw){hwndParent=hw;};
  32.     void SetStyle(unsigned long st){fuStyle=st;};
  33.     void show(char *caption="Error");
  34.     void SetHex(int on_off){is_hex=on_off;};
  35.     WinMessageString& operator<<(char __far *);
  36. #ifndef __BORLANDC__
  37. // Borland doesn't allow overloading based on pointer size
  38.     WinMessageString& operator<<(char *);
  39. #endif
  40.     WinMessageString& operator<<(int);
  41.     WinMessageString& operator<<(long);
  42.     WinMessageString& operator<<(unsigned int);
  43.     WinMessageString& operator<<(unsigned long);
  44. };
  45.